#!/usr/bin/perl -w

use strict; 
use warnings;
my %rc;


chdir $ENV{HOME};


open(RCFILE, ".scrshotrc") or die "Cannot open RC file!";

while ( my $line = readline(RCFILE)) 
{
    if ($line =~ m/^(HOST|USER|PSWD|R_DIR)='([^']+)'/)
	{
		$rc{lc($1)} = $2;
	}
}


use Net::FTP;
my $ftp = Net::FTP->new($rc{host}) or die("Cannot establish connection to host!");
$ftp->login($rc{user},$rc{pswd}) or die("Login incorrect");
$ftp->cwd($rc{r_dir}) or die("Remote directory non-existent");
my @filelist = $ftp->ls();

foreach my $file(@filelist)
{
	$ftp->delete($file) or print $file . "not deleted, perhaps a directory or rights mismatch?";
}

print "FTP clean \n";

